#pragma once

#include <SFML/System/Thread.hpp>

class Sample;

class VocoderThread : public sf::Thread
{
public:
	VocoderThread(void);
	~VocoderThread(void);

	virtual void Run();
	virtual void Stop();
	void FillBuffers();

private:
	volatile bool isRunning;

	Sample* modulator1;
	Sample* modulator2;
	Sample* carrier1;
	Sample* carrier2;
	Sample* vocoded1;
	Sample* vocoded2;
	Sample* vocoded3;
	void InitFirstBuffers();
	void DeleteFirstBuffers();
	void FillWithModulator();
	void FillWithCarrier();
	void FillWithVocoder();
	Sample* NextCrossFaded();
	Sample* CrossFade(Sample* prev, Sample* next);
	Sample* CrossFade(Sample* old, Sample* cur, Sample* next);

};
